package net.huashitong.oversee.service;

import net.huashitong.Project.entity.LeaderShip;
import net.huashitong.Project.service.LeaderShipService;
import net.huashitong.user.databean.BnpUserDatabean;
import net.huashitong.user.entity.BnpUser;
import net.huashitong.user.filter.BnpUserFilter;
import net.huashitong.user.service.BnpUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * 通讯录服务
 */
@Service
public class MailListService {

    @Autowired
    private BnpUserService bnpUserService;

    //县分管领导
    @Autowired
    private LeaderShipService leaderShipService;

    public List<BnpUser> queryAllUserDetail(){
        Map<String,BnpUser> resMap = new HashMap<>();
        BnpUserFilter filter = new BnpUserFilter();
        //查询用户表
        List<BnpUser> bnpUsers = bnpUserService.query();
        bnpUserService.query();
        for(BnpUser b : bnpUsers){
            if(!resMap.containsKey(b.getPhone())){
                resMap.put(b.getPhone(),b);
            }
        }
        //查询县分管领导
        List<LeaderShip> leaderShips = leaderShipService.query();
        for(LeaderShip leaderShip : leaderShips){
            if(!resMap.containsKey(leaderShip.getLeaderPhone())){
                BnpUser bnpUser = new BnpUser();
                bnpUser.setBranch("县分管领导");
                bnpUser.setName(leaderShip.getLeaderName());
                bnpUser.setPhone(leaderShip.getLeaderPhone());
                resMap.put(leaderShip.getLeaderPhone(),bnpUser);
            }
        }
        Collection<BnpUser> valueCollection  = resMap.values();
        List<BnpUser> valueList = new ArrayList<>(valueCollection);
        return valueList;
    }

}
